import type { Address, MedicalOrderDetail,OrderPre } from '@/types/order'
import { request } from '@/utils/http'

/**
 * 收货地址列表
 */
export const addressListApi = () => {
  return request.get<null, Address[]>('/patient/order/address')
}

/**
 * 药品预付订单
 */
export const preOrderApi = (prescriptionId: string) => {
  return request.get<null, OrderPre>('/patient/medicine/order/pre', { params: { prescriptionId } })
}

/**
 * 药品待支付订单
 */
export const createOrderApi = (id: string, addressId: string) => {
  return request.post<null, { id: string }>('/patient/medicine/order', { id, addressId})
}

/**
 * 获取药品订单详情
 * @param id 订单id
 * @returns
 */
export const getMedicalOrderDetail = (id: string) => {
  return request.get<null, MedicalOrderDetail>(`/patient/medicine/order/detail/${id}`)
}